/*
 * @Company: TWL
 * @Author: xue jian
 * @Email: xuejian@kanzhun.com
 * @Date: 2019-11-05 10:45:20
 */
#include "FeatureApiThrift.h"
#include <thrift/transport/TSocket.h>
#include <thrift/transport/TBufferTransports.h>
#include <thrift/protocol/TBinaryProtocol.h>
#include <thrift/transport/TTransportUtils.h>
#include <thrift/processor/TMultiplexedProcessor.h>
#include <thrift/protocol/TMultiplexedProtocol.h>
#include <thrift/protocol/TProtocolDecorator.h>
#include <thrift/processor/TMultiplexedProcessor.h>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <iostream>
#include <string>
#include <sstream>
#include <memory>
using namespace ::apache::thrift;
using namespace ::apache::thrift::protocol;
using namespace ::apache::thrift::transport;
int main(int argc, char** argv) {
    if (argc < 2) {
        std::cerr<<"The service url should be put in"<<std::endl;
    }
    std::string filename(argv[1]);
    std::string ip;
    std::stringstream ss(filename);
    getline(ss, ip, ':');
    std::string str_port;
    getline(ss, str_port, ':');
    int port = std::stoi(str_port);

    std::shared_ptr<TSocket> socket1(new TSocket(ip, port));
    socket1->setRecvTimeout(10000);
    // shared_ptr<TTransport> transport(new TFramedTransport(socket));//for the noblockingserver
    std::shared_ptr<TTransport> fea_transport1(new TFramedTransport(socket1));//for the simpleserver

    std::shared_ptr<TProtocol> fea_protocol1(new TBinaryProtocol(fea_transport1));
    fea_transport1->open();
    std::shared_ptr<FeatureApiThriftClient> fea_client = std::make_shared<FeatureApiThriftClient>(fea_protocol1);

    TBossFeaturesReq tmp_tboss;
    tmp_tboss.uuid = boost::lexical_cast<std::string>(boost::uuids::random_generator()());
    int64_t boss_id(52687737), job_id(43116632);
    tmp_tboss.bossId = boss_id;
    tmp_tboss.jobId = job_id;
    tmp_tboss.sourceType = 0;
    tmp_tboss.featureCodes = {"125", "128", "130", "171", "174", "177", "355", "391", "690", "691", "693", "696", "700", "701", "706", "707", "711", "717", "718", "720", "753", "754", "760", "761", "762", "765", "782", "783", "786", "874", "875", "876", "879", "880", "881", "882", "896", "897", "898", "899", "900"};
    TFeatureResp rsp;
    // resource_global->fea_client->tcmcp_getBossFeatures(rsp, tmp_tboss);
    fea_client->getBossFeatures(rsp, tmp_tboss);

    std::cout<<rsp.respMap.size()<<std::endl;

}